#pragma once
#include "Vector3.h"
#include "MyMatrix.h"
#define TOLERANCE 0.00001
#define PI 3.14159

/*
	A large part of this class was direved from or modified from
	the examples and class methods found on this web page
	http://content.gpwiki.org/index.php/OpenGL:Tutorials:Using_Quaternions_to_represent_rotation
*/

class Quaternion
{
private:
	float _w,_x,_y,_z;
public:

	static const Quaternion NO_ROTATION; 

	Quaternion();
	Quaternion(float w, float x, float y, float z);
	~Quaternion(void);

	void fromAxisAngle(const Vector3<float> &vec, float angle);
	void getAxisAngle(Vector3<float>& axis, double& angle);

	Quaternion OppositeRotation();

	float magnitude();

	void normalise();

	Quaternion conjugate() const;

	Quaternion operator* (const Quaternion &value) const;
	Quaternion operator*= (const Quaternion &value);
	Vector3<float> operator* (const Vector3<float> &value) const;

	MyMatrix asMatrix();

	// static method to make a quat
	static Quaternion AxisAngle(const Vector3<float> &vec, float angle);

};

